package javaTec;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yangshunxing on 2017/8/11.
 */
public class TreeNode {
    public int val;
    public TreeNode left, right;
    public TreeNode(int val) {
        this.val = val;
        this.left = this.right = null;
    }

    public static void main(String[] args) {
        List<Integer> numbers = new ArrayList<>();
        int no = 12204;

        int times = 0;
        for (int i = 0; i < no; i++){
            numbers.add(i);
        }
        boolean circle = true;
        int toDealNum = numbers.size();
            do {
                int index = numbers.size() - toDealNum;
                int toIndex = numbers.size() - toDealNum + 1000;
                if (toDealNum/1000 == 0 && toDealNum%1000 != 0){
                    toIndex = numbers.size() - toDealNum + toDealNum%1000;
                    circle =false;
                }
                List<Integer> uidsTemp = numbers.subList(index, toIndex);
                for (Integer integer: uidsTemp){
                      times++;
                }
                toDealNum = toDealNum - 1000;
            } while (circle);
            System.out.println(times);


    }
}
